pub enum ProductType {
    Type1,
    Type2,
}

pub trait Product {
    fn show(&self);
}

pub trait Factory {
    fn create_prodect(&self, product_type: ProductType) -> Box<dyn Product>;
}

pub struct Product1(String);
pub struct Product2(String);

impl Product for Product1 {
    fn show(&self) {
        println!("color is {}", self.0);
    }
}

impl Product for Product2 {
    fn show(&self) {
        println!("color is {}", self.0);
    }
}

pub struct SimpleFactory;

impl SimpleFactory {
    pub fn new() -> Self {
        Self
    }
}

impl Factory for SimpleFactory {
    fn create_prodect(&self, product_type: ProductType) -> Box<dyn Product> {
        match product_type {
            ProductType::Type1 => Box::new(Product1("black".to_string())),
            ProductType::Type2 => Box::new(Product2("white".to_string())),
        }
    }
}